package com.magina.antiPro.controller;

import com.magina.antiPro.dto.BaiduHot;
import com.magina.antiPro.util.BaiDuHotProcess;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.ArrayList;

//百度股市热门下载
@RestController
public class JsoupGetWebData {

//    @Scheduled(cron = "0/30 0/1 * * * ? ")
    @GetMapping(value = "/getDoubanData")
    public void downBaiduHot(){
        String url = "https://movie.douban.com/";
        try {
            Document doc = Jsoup.connect(url).get();
            //接下来 看抓取的doc的内容去写解析doc的方法
            ArrayList<BaiduHot> abh = new BaiDuHotProcess().processBaiduHot(doc);
            for(BaiduHot b:abh){
                System.out.println(b);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
